package com.yupi.springbootinit.scoring;

import com.yupi.springbootinit.common.UserContext;
import com.yupi.springbootinit.model.entity.App;
import com.yupi.springbootinit.model.entity.UserAnswer;
import com.yupi.springbootinit.model.enums.ScoringStrategyEnum;
import com.yupi.springbootinit.service.QuestionService;
import com.yupi.springbootinit.service.ScoringResultService;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author admin
 * @date 2025/4/24
 */
@ScoringStrategyConfig(appType = 1, scoringStrategy = 0)
public class CustomScoreScoringStrategy implements  ScoringStrategy{

    @Resource
    private ScoringResultService scoringResultService;

    @Resource
    private QuestionService questionService;

    @Override
    public UserAnswer doScore(List<String> choices, App app) {
        Long appId = app.getId();

        // 遍历应用的题目
        UserAnswer userAnswer = new UserAnswer();
        userAnswer.setAppId(appId);
        userAnswer.setAppType(1);
        userAnswer.setScoringStrategy(ScoringStrategyEnum.CUSTOM.getCode());
        userAnswer.setResultName("评分");
        userAnswer.setResultDesc("这是自定义评分");
        userAnswer.setResultPicture("");
        userAnswer.setResultScore(10);
        userAnswer.setUserId(UserContext.getUser().getId());
        userAnswer.setCreateTime(new Date());
        userAnswer.setUpdateTime(new Date());
        // 进行评测
        return userAnswer;
    }
}
